package com.webinsky.domain.user;


public enum Role {
	SuperAdmin(1, "Admin"), ArticleEntry(2, "PostInputMan"), General(3, "General");
	
	private int roleId;
	private String value;
	
	private Role(int roleId, String value){
		this.roleId = roleId;
		this.value = value;
	}
	
	public int getRoleId(){
		return this.roleId;
	}
	
	public String value(){
		return value;
	}
	
	public static Role parse(int roleId){
		for ( Role r : Role.values() ){
			if ( r.getRoleId() == roleId ){
				return r;
			}
		}
		return null;
	}

	public static Role parse(String roleName){
		for ( Role r : Role.values() ){
			if ( r.value().equals(roleName) ){
				return r;
			}
		}
		return null;
	}
	
}
